﻿namespace MicroCloud.Authorization
{
    #region "权限检查结果"
    /// <summary>
    /// 权限检查结果
    /// </summary>
    [DebuggerDisplay("{ResultType}-{Message}")]
    public sealed class AuthorizationResult : ResultBase<AuthorizationStatus>
    {
        #region "属性"
        #region "获取或设置 返回消息"
        /// <summary>
        /// 获取或设置 返回消息
        /// </summary>
        public override string Message
        {
            get { return _message ?? ResultType.ToDescription(); }
            set { _message = value; }
        }
        #endregion
        #region "获取 是否 <see cref="AuthorizationStatus.OK"/>"
        /// <summary>
        /// 获取 是否 <see cref="AuthorizationStatus.OK"/>
        /// </summary>
        public bool IsOk
        {
            get { return ResultType == AuthorizationStatus.OK; }
        }
        #endregion
        #region "获取 是否 <see cref="AuthorizationStatus.Unauthorized"/>"
        /// <summary>
        /// 获取 是否 <see cref="AuthorizationStatus.Unauthorized"/>
        /// </summary>
        public bool IsUnauthorized
        {
            get { return ResultType == AuthorizationStatus.Unauthorized; }
        }
        #endregion
        #region "获取 是否 <see cref="AuthorizationStatus.Forbidden"/>"
        /// <summary>
        /// 获取 是否 <see cref="AuthorizationStatus.Forbidden"/>
        /// </summary>
        public bool IsForbidden
        {
            get { return ResultType == AuthorizationStatus.Forbidden; }
        }
        #endregion
        #region "获取 是否 <see cref="AuthorizationStatus.NoFound"/>"
        /// <summary>
        /// 获取 是否 <see cref="AuthorizationStatus.NoFound"/>
        /// </summary>
        public bool IsNoFound
        {
            get { return ResultType == AuthorizationStatus.NoFound; }
        }
        #endregion
        #region "获取 是否 <see cref="AuthorizationStatus.Locked"/>"
        /// <summary>
        /// 获取 是否 <see cref="AuthorizationStatus.Locked"/>
        /// </summary>
        public bool IsLocked
        {
            get { return ResultType == AuthorizationStatus.Locked; }
        }
        #endregion
        #region "获取 是否 <see cref="AuthorizationStatus.Error"/>"
        /// <summary>
        /// 获取 是否 <see cref="AuthorizationStatus.Error"/>
        /// </summary>
        public bool IsError
        {
            get { return ResultType == AuthorizationStatus.Error; }
        }
        #endregion
        #region "获取 检查成功的结果"
        /// <summary>
        /// 获取 检查成功的结果
        /// </summary>
        public static AuthorizationResult OK { get; } = new AuthorizationResult(AuthorizationStatus.OK);
        #endregion

        #endregion

        #region "构造函数"
        #region "初始化一个权限检查结果的新实例"
        /// <summary>
        /// 初始化一个权限检查结果 <see cref="AuthorizationResult"/> 的新实例
        /// </summary>
        /// <param name="status"></param>
        public AuthorizationResult(AuthorizationStatus status)
            : this(status, null)
        { }
        #endregion
        #region "初始化一个权限检查结果的新实例"
        /// <summary>
        /// 初始化一个权限检查结果 <see cref="AuthorizationResult"/> 的新实例
        /// </summary>
        /// <param name="status"></param>
        /// <param name="message"></param>
        public AuthorizationResult(AuthorizationStatus status, string message)
            : this(status, message, null)
        { }
        #endregion
        #region "初始化一个权限检查结果的新实例"
        /// <summary>
        /// 初始化一个权限检查结果 <see cref="AuthorizationResult"/> 的新实例
        /// </summary>
        /// <param name="status"></param>
        /// <param name="message"></param>
        /// <param name="data"></param>
        public AuthorizationResult(AuthorizationStatus status, string message, object data)
            : base(status, message, data)
        { }
        #endregion

        #endregion

    }
    #endregion

}
